var webName="/myproject4.0/UserServlet?type=";

$(function(){
	getUserPage()
})

//加载分页集合数据
function getUserPage(){
	alert(getPage(10, 1, 10, '#'));
	$.getJSON(webName+"getUserPage",{},function(list){
		var tbody=$("#tbody");
		tbody.html("");
		for (var i = 0; i < list.length; i++) {
			tbody.append("<tr>");
			tbody.append('<td><input type="checkbox" /></td>');
			tbody.append("<td>"+list[i].id+"</td>");
			tbody.append("<td>"+list[i].name+"</td>");
			tbody.append("<td>"+list[i].pwd+"</td>");
			tbody.append("<td>"+list[i].rinfo.name+"</td>");
			tbody.append('<a href="#" title="Edit"><img src="resources/images/icons/pencil.png" alt="Edit" /></a> ');
			tbody.append('&nbsp;&nbsp;<a href="javascript:deleteUser('+list[i].id+')" title="Delete"><img src="resources/images/icons/cross.png" alt="Delete" /></a>');
			tbody.append("</tr>");
		}
	});

	$(".pagination").html(getPage(10, 1, 1001, webName+"getUserPage"));
}

//删除数据
function deleteUser(id){
	$.get(webName+"deleteUser",{"id":id},function(data){
		if(data==1)
			getUserPage();
		else
			alert('服务器异常,请联系管理员');
	})
}



























